package de.vocabulary.client.service;

import java.util.List;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;

import de.vocabulary.client.editor.VocableTable;
import de.vocabulary.shared.model.Vocable;



/** * Class which handles the asynchronous callback from the server * <p> * Need to react on server communication failure and success * * @author Lars Vogel * */

public class MyVocabularyCallback implements AsyncCallback<List<Vocable>> {

  private VocableTable table;
  private boolean loading = true;

  public MyVocabularyCallback(VocableTable table, boolean loading) {
    this.table = table;
    this.loading = loading;
  }

  public void onFailure(Throwable caught) {
    Window.alert(caught.getMessage());
  }

  public void onSuccess(List<Vocable> result) {
 /*   if (loading){
    	table.setInput(result);
    }
    else
    	table.addInput(result);*/
	  for(Vocable v: result){
		  System.out.println("Received: "+v);
		  table.addVocable(v);
	  }
   
  }

} 